﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using MeizuSDK.Presentation;

namespace Demo
{
    class MultiTouchWindow : DemoWindowBase
    {
        Button button1 = new Button();
        Button button2 = new Button();

        public MultiTouchWindow()
        {
            button1.Size = new Size(0, 0);
            button2.Size = new Size(0, 0);

            Controls.Add(button1);
            Controls.Add(button2);

            this.Touch += new EventHandler<MultiTouchEventArgs>(MultiTouchWindow_Touch);
        }

        void MultiTouchWindow_Touch(object sender, Form.MultiTouchEventArgs e)
        {
            button1.Size = new Size(0, 0);
            button2.Size = new Size(0, 0);

            if (e.Touches.Count > 0)
            {
                ShowTouch(button1, e.Touches[0]);
            }

            if (e.Touches.Count > 1)
            {
                ShowTouch(button2, e.Touches[1]);
            }
        }

        void ShowTouch(Button btn, TouchData touch)
        {
            btn.Size = new Size(touch.Z, touch.Z);
            btn.Location = new Point(touch.X - touch.Z / 2, touch.Y - touch.Z / 2);
        }
    }
}